package com.example.yunbiji0314.controller;

import com.example.yunbiji0314.service.OrderService;
import com.example.yunbiji0314.util.Code;
import com.example.yunbiji0314.util.Result;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/addorder")
    @ApiModelProperty(value = "添加订单表和订单商品表")
    public Result addorder(@RequestBody Map map){
        System.out.println(map);
        try {
            orderService.addOrder(map);
            return new Result(Code.SAVE_OK,"添加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(Code.SAVE_ERR,"添加失败");
        }
    }}
